package com.heyu.cgsd.ui.fragment

import android.support.v4.app.Fragment
import android.support.v4.app.FragmentPagerAdapter
import android.support.v4.view.PagerAdapter
import com.heyu.cgsd.R
import com.heyu.cgsd.base.BaseFragment
import com.heyu.cgsd.ui.activity.CalculatorActivity
import kotlinx.android.synthetic.main.fragment_home.*

/**
 * FileName: HomeFragment
 * Author: admin
 * Date: 2021/3/12 17:47
 * Description:
 */
class HomeFragment : BaseFragment() {

    override fun getContentView(): Int {
        return R.layout.fragment_home
    }

    override fun initView() {
        super.initView()
        initViewPager()
        tv_right.setOnClickListener {
            startAct(_mActivity, CalculatorActivity())
        }
    }

    private fun initViewPager() {
        val fpAdapter: FragmentPagerAdapter = object : FragmentPagerAdapter(_mActivity.supportFragmentManager) {
            override fun getItem(position: Int): Fragment {
                return SelectFragment.newInstance(position)
            }

            override fun getItemPosition(`object`: Any): Int {
                return PagerAdapter.POSITION_NONE
            }

            override fun getCount(): Int {
                return 1
            }
        }
        vp_select.adapter = fpAdapter
    }
}